// index.js文件
import { defineAsyncComponent } from 'vue'
import type { App } from 'vue'

/**
 * @description 在src/components目录下创建文件，即 src/components/xxx.vue
 * @description 在src/components目录下创建目录及文件，即 src/components/xxx文件夹/xxx.vue
 */
const components = import.meta.glob('./*/index.vue')
// console.log(components,'components++++++++++++++++++');
export default function install(app: App) {
  for (const [key, value] of Object.entries(components)) {
    // console.log(key,'key++++++++++++++++++++++++++++++++');
    const name = key.replace('./', '').split('/')[0]
    // console.log(name,'name+++++++++++++++++++++++++++++');
    app.component(name, defineAsyncComponent(value as any))
  }
}
